﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using eTerm.Platform.Business;
using System.IO;
using eTerm.MsSql.DbProvider;

namespace eTerm.Platform.Web.PNR
{
    public partial class ExportExcel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filename = string.Format("票号列表{0}.xls",DateTime.Now.ToString(@"yyyyMMddHHmmss"));
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", filename));
            Response.Clear();
            string QueryStr = Request["QueryStr"];
            string StartDate = Request["StartDate"];
            string EndDate = Request["EndDate"];
            string UID = Request["UID"];
            string StatusID = Request["StatusID"]??"1";

            Response.BinaryWrite((new NPOIDetr().ToExcel(string.Empty, UID==@"0" ? null : int.Parse(UID) as int?, string.IsNullOrEmpty(StartDate) ? null : DateTime.Parse(StartDate) as DateTime?, string.IsNullOrEmpty(EndDate) ? null : DateTime.Parse(EndDate) as DateTime?, int.Parse(StatusID)) as MemoryStream).GetBuffer());
            Response.End();
        }
    }
}
